\(\int \sqrt {a+b \cot ^2(x)} \, dx\) [23]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [B] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [F(-2)]
   Giac [B] (verification not implemented)
   Mupad [F(-1)]

Optimal result

Integrand size = 12, antiderivative size = 65 \[ \int \sqrt {a+b \cot ^2(x)} \, dx=-\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\sqrt {b} \text {arctanh}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right ) \]

[Out]

-arctan(cot(x)*(a-b)^(1/2)/(a+b*cot(x)^2)^(1/2))*(a-b)^(1/2)-arctanh(cot(x)*b^(1/2)/(a+b*cot(x)^2)^(1/2))*b^(1
/2)

Rubi [A] (verified)

Time = 0.05 (sec) , antiderivative size = 65, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.500, Rules used = {3742, 399, 223, 212, 385, 209} \[ \int \sqrt {a+b \cot ^2(x)} \, dx=-\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\sqrt {b} \text {arctanh}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right ) \]

[In]

Int[Sqrt[a + b*Cot[x]^2],x]

[Out]

-(Sqrt[a - b]*ArcTan[(Sqrt[a - b]*Cot[x])/Sqrt[a + b*Cot[x]^2]]) - Sqrt[b]*ArcTanh[(Sqrt[b]*Cot[x])/Sqrt[a + b
*Cot[x]^2]]

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 223

Int[1/Sqrt[(a_) + (b_.)*(x_)^2], x_Symbol] :> Subst[Int[1/(1 - b*x^2), x], x, x/Sqrt[a + b*x^2]] /; FreeQ[{a,
b}, x] &&  !GtQ[a, 0]

Rule 385

Int[((a_) + (b_.)*(x_)^(n_))^(p_)/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Subst[Int[1/(c - (b*c - a*d)*x^n), x]
, x, x/(a + b*x^n)^(1/n)] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && EqQ[n*p + 1, 0] && IntegerQ[n]

Rule 399

Int[((a_) + (b_.)*(x_)^(n_))^(p_)/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Dist[b/d, Int[(a + b*x^n)^(p - 1), x]
, x] - Dist[(b*c - a*d)/d, Int[(a + b*x^n)^(p - 1)/(c + d*x^n), x], x] /; FreeQ[{a, b, c, d, p}, x] && NeQ[b*c
 - a*d, 0] && EqQ[n*(p - 1) + 1, 0] && IntegerQ[n]

Rule 3742

Int[((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x]
, x]}, Dist[c*(ff/f), Subst[Int[(a + b*(ff*x)^n)^p/(c^2 + ff^2*x^2), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ
[{a, b, c, e, f, n, p}, x] && (IntegersQ[n, p] || IGtQ[p, 0] || EqQ[n^2, 4] || EqQ[n^2, 16])

Rubi steps \begin{align*} \text {integral}& = -\text {Subst}\left (\int \frac {\sqrt {a+b x^2}}{1+x^2} \, dx,x,\cot (x)\right ) \\ & = -\left (b \text {Subst}\left (\int \frac {1}{\sqrt {a+b x^2}} \, dx,x,\cot (x)\right )\right )+(-a+b) \text {Subst}\left (\int \frac {1}{\left (1+x^2\right ) \sqrt {a+b x^2}} \, dx,x,\cot (x)\right ) \\ & = -\left (b \text {Subst}\left (\int \frac {1}{1-b x^2} \, dx,x,\frac {\cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )\right )+(-a+b) \text {Subst}\left (\int \frac {1}{1-(-a+b) x^2} \, dx,x,\frac {\cot (x)}{\sqrt {a+b \cot ^2(x)}}\right ) \\ & = -\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\sqrt {b} \text {arctanh}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right ) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.17 (sec) , antiderivative size = 78, normalized size of antiderivative = 1.20 \[ \int \sqrt {a+b \cot ^2(x)} \, dx=\sqrt {a-b} \arctan \left (\frac {-\cot (x) \sqrt {a+b \cot ^2(x)}+\sqrt {b} \csc ^2(x)}{\sqrt {a-b}}\right )+\sqrt {b} \log \left (-\sqrt {b} \cot (x)+\sqrt {a+b \cot ^2(x)}\right ) \]

[In]

Integrate[Sqrt[a + b*Cot[x]^2],x]

[Out]

Sqrt[a - b]*ArcTan[(-(Cot[x]*Sqrt[a + b*Cot[x]^2]) + Sqrt[b]*Csc[x]^2)/Sqrt[a - b]] + Sqrt[b]*Log[-(Sqrt[b]*Co
t[x]) + Sqrt[a + b*Cot[x]^2]]

Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(136\) vs. \(2(53)=106\).

Time = 0.05 (sec) , antiderivative size = 137, normalized size of antiderivative = 2.11

method result size
derivativedivides \(-\sqrt {b}\, \ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \cot \left (x \right )^{2}}\right )+\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b \left (a -b \right )}-\frac {a \sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b^{2} \left (a -b \right )}\) \(137\)
default \(-\sqrt {b}\, \ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \cot \left (x \right )^{2}}\right )+\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b \left (a -b \right )}-\frac {a \sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b^{2} \left (a -b \right )}\) \(137\)

[In]

int((a+b*cot(x)^2)^(1/2),x,method=_RETURNVERBOSE)

[Out]

-b^(1/2)*ln(b^(1/2)*cot(x)+(a+b*cot(x)^2)^(1/2))+(b^4*(a-b))^(1/2)/b/(a-b)*arctan(b^2*(a-b)/(b^4*(a-b))^(1/2)/
(a+b*cot(x)^2)^(1/2)*cot(x))-a*(b^4*(a-b))^(1/2)/b^2/(a-b)*arctan(b^2*(a-b)/(b^4*(a-b))^(1/2)/(a+b*cot(x)^2)^(
1/2)*cot(x))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 124 vs. \(2 (53) = 106\).

Time = 0.28 (sec) , antiderivative size = 515, normalized size of antiderivative = 7.92 \[ \int \sqrt {a+b \cot ^2(x)} \, dx=\left [\frac {1}{2} \, \sqrt {-a + b} \log \left (-{\left (a - b\right )} \cos \left (2 \, x\right ) + \sqrt {-a + b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) + b\right ) + \frac {1}{2} \, \sqrt {b} \log \left (\frac {{\left (a - 2 \, b\right )} \cos \left (2 \, x\right ) + 2 \, \sqrt {b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) - a - 2 \, b}{\cos \left (2 \, x\right ) - 1}\right ), -\sqrt {a - b} \arctan \left (-\frac {\sqrt {a - b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{{\left (a - b\right )} \cos \left (2 \, x\right ) + a - b}\right ) + \frac {1}{2} \, \sqrt {b} \log \left (\frac {{\left (a - 2 \, b\right )} \cos \left (2 \, x\right ) + 2 \, \sqrt {b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) - a - 2 \, b}{\cos \left (2 \, x\right ) - 1}\right ), \sqrt {-b} \arctan \left (\frac {\sqrt {-b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{b \cos \left (2 \, x\right ) + b}\right ) + \frac {1}{2} \, \sqrt {-a + b} \log \left (-{\left (a - b\right )} \cos \left (2 \, x\right ) + \sqrt {-a + b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) + b\right ), -\sqrt {a - b} \arctan \left (-\frac {\sqrt {a - b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{{\left (a - b\right )} \cos \left (2 \, x\right ) + a - b}\right ) + \sqrt {-b} \arctan \left (\frac {\sqrt {-b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{b \cos \left (2 \, x\right ) + b}\right )\right ] \]

[In]

integrate((a+b*cot(x)^2)^(1/2),x, algorithm="fricas")

[Out]

[1/2*sqrt(-a + b)*log(-(a - b)*cos(2*x) + sqrt(-a + b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x
) + b) + 1/2*sqrt(b)*log(((a - 2*b)*cos(2*x) + 2*sqrt(b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2
*x) - a - 2*b)/(cos(2*x) - 1)), -sqrt(a - b)*arctan(-sqrt(a - b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1
))*sin(2*x)/((a - b)*cos(2*x) + a - b)) + 1/2*sqrt(b)*log(((a - 2*b)*cos(2*x) + 2*sqrt(b)*sqrt(((a - b)*cos(2*
x) - a - b)/(cos(2*x) - 1))*sin(2*x) - a - 2*b)/(cos(2*x) - 1)), sqrt(-b)*arctan(sqrt(-b)*sqrt(((a - b)*cos(2*
x) - a - b)/(cos(2*x) - 1))*sin(2*x)/(b*cos(2*x) + b)) + 1/2*sqrt(-a + b)*log(-(a - b)*cos(2*x) + sqrt(-a + b)
*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x) + b), -sqrt(a - b)*arctan(-sqrt(a - b)*sqrt(((a - b)
*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x)/((a - b)*cos(2*x) + a - b)) + sqrt(-b)*arctan(sqrt(-b)*sqrt(((a -
b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x)/(b*cos(2*x) + b))]

Sympy [F]

\[ \int \sqrt {a+b \cot ^2(x)} \, dx=\int \sqrt {a + b \cot ^{2}{\left (x \right )}}\, dx \]

[In]

integrate((a+b*cot(x)**2)**(1/2),x)

[Out]

Integral(sqrt(a + b*cot(x)**2), x)

Maxima [F(-2)]

Exception generated. \[ \int \sqrt {a+b \cot ^2(x)} \, dx=\text {Exception raised: ValueError} \]

[In]

integrate((a+b*cot(x)^2)^(1/2),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(b-a>0)', see `assume?` for mor
e details)Is

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 210 vs. \(2 (53) = 106\).

Time = 0.50 (sec) , antiderivative size = 210, normalized size of antiderivative = 3.23 \[ \int \sqrt {a+b \cot ^2(x)} \, dx=-\frac {1}{2} \, {\left (\frac {2 \, \sqrt {-a + b} b \arctan \left (\frac {{\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{2} + a - 2 \, b}{2 \, \sqrt {a b - b^{2}}}\right )}{\sqrt {a b - b^{2}}} + \sqrt {-a + b} \log \left ({\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{2}\right )\right )} \mathrm {sgn}\left (\sin \left (x\right )\right ) - \frac {{\left (2 \, \sqrt {-a + b} b \arctan \left (\frac {\sqrt {-a + b} \sqrt {b}}{\sqrt {a b - b^{2}}}\right ) - \sqrt {a b - b^{2}} \sqrt {-a + b} \log \left (-a - 2 \, \sqrt {-a + b} \sqrt {b} + 2 \, b\right )\right )} \mathrm {sgn}\left (\sin \left (x\right )\right )}{2 \, \sqrt {a b - b^{2}}} \]

[In]

integrate((a+b*cot(x)^2)^(1/2),x, algorithm="giac")

[Out]

-1/2*(2*sqrt(-a + b)*b*arctan(1/2*((sqrt(-a + b)*cos(x) - sqrt(-a*cos(x)^2 + b*cos(x)^2 + a))^2 + a - 2*b)/sqr
t(a*b - b^2))/sqrt(a*b - b^2) + sqrt(-a + b)*log((sqrt(-a + b)*cos(x) - sqrt(-a*cos(x)^2 + b*cos(x)^2 + a))^2)
)*sgn(sin(x)) - 1/2*(2*sqrt(-a + b)*b*arctan(sqrt(-a + b)*sqrt(b)/sqrt(a*b - b^2)) - sqrt(a*b - b^2)*sqrt(-a +
 b)*log(-a - 2*sqrt(-a + b)*sqrt(b) + 2*b))*sgn(sin(x))/sqrt(a*b - b^2)

Mupad [F(-1)]

Timed out. \[ \int \sqrt {a+b \cot ^2(x)} \, dx=\int \sqrt {b\,{\mathrm {cot}\left (x\right )}^2+a} \,d x \]

[In]

int((a + b*cot(x)^2)^(1/2),x)

[Out]

int((a + b*cot(x)^2)^(1/2), x)